﻿$(function() {
    SentenceUpdate.init();
    Utils.textBoxsOnEnter(SentenceUpdate._Save);
});


var SentenceUpdate =
{
    init: function() {
        $("#btnSave").click(this._Save);
        $("#category").focus();
        $(document).keyup(function(e) {
            if (e.keyCode == 27) {
                var needConfirm = utility.hasFormData();
                window.parent.utility.closePopUpUrlConfirm(needConfirm);
            }
        });
    }
    , _Save: function() {
        var sn = $("#sn");
        var category = $("#category");

        targetFunction = (parent != undefined) ? parent.ErrorHelper : ErrorHelper;
        targetFunction.checkNonNull(category, m.Err1107);
        if (!targetFunction.popUpIfError()) {
            var param = {
                sn: sn.val()
                , category: category.val()
            };
            var cb = Utils.getCBfunction('Sentence', 'CategoryIndex');
            var ecb = function() { $("#category").focus(); };
            window.parent.utility.ajaxext("SentenceService/UpdateCategory", param, "POST", cb, ecb);
        }
    }
};